package com.tbit.uqbike.webmanager.controller;

import com.tbit.uqbike.object.pojo.dto.SimDTO;
import com.tbit.uqbike.object.pojo.vo.SimVo;
import com.tbit.common.entity.view.PageResult;
import com.tbit.common.entity.view.Result;
import com.tbit.uqbike.service.business.SimManageService;
import com.tbit.uqbike.webmanager.util.excel.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * sim卡管理
 *
 * @Author LHX
 * @ClassName SimManageController
 * @Description
 * @date 2023/5/5 11:49
 * @Version 1.0
 */
@RestController
@RequestMapping("/simManage")
public class SimManageController {

    @Autowired
    private SimManageService simManageService;

    /**
     * 分页查询SIM卡信息
     *
     * @param simDTO
     * @return
     */
    @PostMapping("/queryPage")
    public Result<PageResult<SimVo>> queryPage(@RequestBody SimDTO simDTO) {
        PageResult<SimVo> pageResult = simManageService.queryPage(simDTO);
        return Result.success(pageResult);
    }

    /**
     * 导出SIM卡信息
     *
     * @param simDTO
     * @return
     */
    @GetMapping("/export")
    public Result<Object> export(SimDTO simDTO) {
        List<SimVo> list = simManageService.export(simDTO);
        ExcelUtil<SimVo> simVoExcelUtil = new ExcelUtil<>(SimVo.class);
        return Result.success(simVoExcelUtil.exportExcel(list, "sim卡到期信息").getData());
    }
}
